package business.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Required;
import org.springframework.transaction.annotation.Transactional;

import vo.UserGroup;
import business.UserGroupService;
import dao.UserGroupDAO;

public class UserGroupServiceImpl implements UserGroupService {

	private UserGroupDAO userGroupDao;

	public List<UserGroup> getAllUserGroups() {
		return userGroupDao.findAll();
	}

	public UserGroup getByName(String name) {
		return userGroupDao.findByName(name);
	}
	@Required
	public void setUserGroupDao(UserGroupDAO userGroupDao) {
		this.userGroupDao = userGroupDao;
	}

	@Transactional
	public void addUserGroup(String name) {
		UserGroup e = new UserGroup();
		e.setName(name);
		userGroupDao.create(e);
	}

	@Transactional
	public void addUserGroup(UserGroup userGroup) {
		userGroupDao.create(userGroup);
	}

	@Transactional
	public UserGroup getById(long id) {
		return userGroupDao.getById(id);
	}

	@Transactional
	public void update(long id) {
		userGroupDao.update(id);
	}

	@Transactional
	public void delete(long id) {// 真正删除
		userGroupDao.delete(id);
	}

}